<?php
namespace app\member\controller;
use app\AdminRest;
use app\member\model\Goods;
use app\member\model\Level;
use app\member\model\RightsRelation;
use longbingcore\wxcore\WxSetting;
use think\App;
use app\member\model\Config as model;



class AdminConfig extends AdminRest
{

    protected $model;


    public function __construct(App $app) {

        parent::__construct($app);

        $this->model = new model();

    }




    /**
     * @author chenniang
     * @DataTime: 2020-07-15 11:21
     * @功能说明:会员配置详情
     */
    public function configInfo(){

        $input = $this->_param;

        $dis = [

            'uniacid' => $this->_uniacid
        ];

        $data = $this->model->configInfo($dis);

        if(!empty($data['commission_user'])){

            $data['commission_user'] = array_values(explode(',',$data['commission_user']));

        }

        if(empty($data)){

            $this->errorMsg('数据未找到');
        }

        return $this->success($data);

    }


    /**
     * @author chenniang
     * @DataTime: 2020-07-15 13:24
     * @功能说明:配置编辑
     */
    public function configUpdate(){

        $input = $this->_input;

        $dis = [

            'uniacid' => $this->_uniacid
        ];

        if(!empty($input['commission_user'])){

            $input['commission_user'] = implode(',',$input['commission_user']);
        }
//        dump($input);exit;
        $data = $this->model->configUpdate($dis,$input);

        return $this->success($data);

    }


    /**
     * @author chenniang
     * @DataTime: 2020-09-10 09:43
     * @功能说明:佣金下拉框
     */
    public function commissionSelect(){

        $level_model = new Level();

        $dis = [

            'status' => 1,

            'uniacid'=> $this->_uniacid
        ];

        $level = $level_model->where($dis)->field(['top'=>'value','title'=>'name'])->select()->toArray();

        $arr   = [

            ['value'=>1000,'name'=>'全部'],

            ['value'=>888,'name'=>'员工'],

            ['value'=>777,'name'=>'普通用户'],

        ];

        $arr = array_merge($arr,$level);

        return $this->success($arr);
    }










}
